home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: gets() question
- Date: Tue, 09 Jan 96 01:37:04 GMT
- Organization: none
- Message-ID: <821151424snz@genesis.demon.co.uk>
- References: <4cosgf$rir@newsbf02.news.aol.com> <4cqkt8$1quo@news.gate.net> <TANMOY.96Jan8084126@qcd.lanl.gov>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <TANMOY.96Jan8084126@qcd.lanl.gov>
- tanmoy@qcd.lanl.gov "Tanmoy Bhattacharya" writes:
-
- >--text follows this line--
- >In article <821109116snz@genesis.demon.co.uk> Lawrence Kirby
- ><fred@genesis.demon.co.uk> writes:
- ><snip>
- > It is certainly better to use fgets rather than gets but you could have
- > written:
- >
- > fgets(s[0],sizeof s[0],stdin);
- >
- > s[0] is equivalent to &s[0][0] in this context and is arguably more
- > readable. The length argument of fgets specifies the size of the array
- >
- >Just to point out the obvious, the first s[0] is equivalent to
- >&s[0][0]. The s[0] in sizeof s[0] is not!
-
- Right! You might consider that neither & not sizeof take the value of
- their operand (i.e. treat it as an rvalue). & takes an lvalue and returns
- a pointer to the dsignated object, and sizeof takes an explicit type or the
- type from an expression (but not the value, indeed the expression is not
- evaluated at all).
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-